package com.ruoyi.common.core.enums;

import com.ruoyi.common.core.exception.CustomException;

import java.util.Arrays;
import java.util.List;

/**
 * @Auther: tswsoft
 * @Date: 2021/03/24/3:27 PM
 * @Description: 来源平台
 */
public enum SrcPlatformEnum {

    /**
     *
     */
    PLATFORM_2B("PLATFORM_2B", "平台_2B"),
    DA_HAI_BANG("DA_HAI_BANG", "大海帮"),
    PING_DUO_DUO("PING_DUO_DUO", "拼多多"),
    YOU_ZAN("YOU_ZAN", "有赞"),
    EWS("EWS", "第E仓"),
    SU_NING("SU_NING", "苏宁"),
    DISTRIBUTOR("DISTRIBUTOR", "分销商"),
    YU_XIN_HUI("YU_XIN_HUI", "渝新汇"),
    DONG_XI_JI("DONG_XI_JI", "东西集"),
    ECOM_BIRD("ECOM_BIRD", "候鸟"),
    HAI_DAI_WANG("HAI_DAI_WANG", "海带网"),
    BAO_MA("BAO_MA", "宝妈时光"),
    HAI_PAI_KE("HAI_PAI_KE", "海拍客"),
    JD("JD", "京东"),
    XIAO_HONG_SHU("XIAO_HONG_SHU", "小红书"),
    FKMALLS("FKMALLS","Fkmalls"),
    WEINI_HAIGOU("WEINI_HAIGOU","维妮海购"),
    YI_JIE("YI_JIE", "易捷"),
    DA_V("DA_V", "大V店"),
    CHONG_MING_DA("CHONG_MING_DA", "崇名达"),
    KUA_JING_TONG("KUA_JING_TONG","跨境通"),
    AO_AN("AO_AN", "澳安"),
    BAI_BAO("BAI_BAO", "小小包麻麻"),
    DONGGUAN_CHENGZI("DONGGUAN_CHENGZI", "东莞橙子"),
    SHANG_HE_GOU("SHANG_HE_GOU","上禾购"),
    YU_LE("YU_LE","禹乐"),
    GUO_JI_MA_MI("GUO_JI_MA_MI","国际妈咪"),
    LE_TAO_KE("LE_TAO_KE","乐淘客"),
    LIAN_TONG("LIAN_TONG","联童"),
    LIAN_DUO_DUO("LIAN_DUO_DUO","链多多"),
    XIN_XIANG_YUN("XIN_XIANG_YUN","新享云"),
    YA_MEI_DA("YA_MEI_DA","雅美达"),
    JING_TONG("JING_TONG","景彤"),
    YI_JIE_V2("YI_JIE_V2","易捷2.0"),
    YI_BEI_YUN_CANG("YI_BEI_YUN_CANG","易贝云仓"),
    A_KANG("A_KANG","阿康"),
    AI_KU_CUN("AI_KU_CUN","爱库存"),
    YOU_A("YOU_A","友阿"),
    XING_YUN("XING_YUN","行云"),
    BEI_ER_XIN("BEI_ER_XIN","贝儿欣"),
    BI_DE_TAI_KE("BI_DE_TAI_KE","比徳泰克"),
    YANG_JING("YANG_JING","洋鲸"),
    NIAN_FENG_DA_DANG_JIA("NIAN_FENG_DA_DANG_JIA","年丰大当家"),
    DXJ_JIU_ZHANG("DXJ_JIU_ZHANG","东西集-九章"),
    HAI_ZI_WANG("HAI_ZI_WANG","孩子王"),
    JIN_YING_GOU ("JIN_YING_GOU","金鹰购"),
    TONG_CHENG_INTERNATIONAL("TONG_CHENG_INTERNATIONAL","通城国际"),
    SHOU_MIAN("SHOU_MIAN","首免"),
    TMALL("TMALL","天猫"),
    JD_YPH("JD_YPH","京东一盘货"),
    JD_GX("JD_GX","京东-供销"),
    JD_GY("JD_GY","京东-供应"),
    QUAN_QIU_YUN_LIAN("QUAN_QIU_YUN_LIAN","全球云链"),
    KA_JD("KA_JD","KA京东"),
    KA_ALI_JK("KA_ALI_JK","KA阿里健康"),
    KAOLA("KAOLA","考拉"),
    KA_TMALL_TDI("KA_TMALL_TDI","KA天猫TDI"),
    VIP_SHOP("VIP_SHOP","唯品会"),
    TMALL_YINHE("TMALL_YINHE","天猫银河分销"),
    DING_XIANG_YUAN("DING_XIANG_YUAN","丁香园"),
    YAN_JIAO_SHOU("YAN_JIAO_SHOU","燕教授"),
    MEIAH("MEIAH","美亚"),
    UYUY("UYUY","余外"),
    HAI_JU_GOU("HAI_JU_GOU","海聚购"),
    CW("CW","CW"),

    ;


    private final String code;
    private final String name;

    SrcPlatformEnum(String code, String name)
    {
        this.code = code;
        this.name = name;
    }

    public String getCode()
    {
        return code;
    }

    public String getName()
    {
        return name;
    }

    public static String getNameByCode(String code) {
        for (SrcPlatformEnum item : SrcPlatformEnum.values()) {
            if (item.getCode().equals(code)) {
                return item.getName();
            }
        }
        return "";
    }

    public static String getCodeByName(String name) {
        for (SrcPlatformEnum item : SrcPlatformEnum.values()) {
            if (item.getName().equals(name)) {
                return item.code;
            }
        }
        return null;
    }

    public static SrcPlatformEnum parseByCode(String code) {
        for (SrcPlatformEnum item : SrcPlatformEnum.values()) {
            if (item.getCode().equals(code)) {
                return item;
            }
        }
        throw new CustomException("平台编码转换失败");
    }

    /**
     * 判断平台是否是分销平台（目前只有京东一盘货一个）
     * @param platformCode
     * @return
     */
    public static Boolean isDistributionPlatform(String platformCode) {
        return Arrays.asList(SrcPlatformEnum.JD_YPH.getCode(), JD_GX.getCode()).contains(platformCode);
    }

    /**
     * 判断平台是否订单信息包含子订单
     * @param platformCode
     * @return
     */
    public static Boolean isMultiOrderPlatform(String platformCode) {
        List<String> multiOrderPlatformList = Arrays.asList(SrcPlatformEnum.TMALL.getCode(), SrcPlatformEnum.TMALL_YINHE.getCode());
        return multiOrderPlatformList.contains(platformCode);
    }

    /**
     * 支持导入的平台
     * @return
     */
    public static List<String> enableImportPlatformList() {
        return Arrays.asList(SrcPlatformEnum.DISTRIBUTOR.getCode(), SrcPlatformEnum.FKMALLS.getCode(), SrcPlatformEnum.WEINI_HAIGOU.getCode());
    }

    /**
     * 判断平台是否是支持导入的平台
     * @param platformCode
     * @return
     */
    public static Boolean isEnableImportPlatform(String platformCode) {
        return SrcPlatformEnum.enableImportPlatformList().contains(platformCode);
    }
}
